package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.common.utils.ScreenUtils;
import com.ssyc.common.utils.UiUtils;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.TeacherManagerInfo;

import java.util.List;

/**
 * 教师管理的列表适配器
 * Created by Administrator on 2018/7/16 0016.
 */

public class TeacherManagerRvAdapter extends BaseQuickAdapter<TeacherManagerInfo.ListBean, BaseViewHolder> {
    private Context context;
    private LinearLayout.LayoutParams lp;

    public TeacherManagerRvAdapter(Context context, int layoutResId, @Nullable List<TeacherManagerInfo.ListBean> data) {
        super(layoutResId, data);
        this.context = context;
        int screenWidth = ScreenUtils.getScreenWidth(context);
        lp = new LinearLayout.LayoutParams((screenWidth - UiUtils.dp2px(18 * 2)) / 4, ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    @Override
    protected void convert(BaseViewHolder helper, TeacherManagerInfo.ListBean item) {

        //外层布局
        RelativeLayout rlOut = helper.getView(R.id.rl_out);
        rlOut.setLayoutParams(lp);

        //头像
        RoundedImageView ivHead = helper.getView(R.id.iv_head);
        ImageUtil.displayImage(context, ivHead, item.getIcon(), R.drawable.defaultimage);

        //姓名
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getName());
    }
}
